﻿<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="com.zaofan.bean.Admin"%>
<%@page import="com.zaofan.bean.AdminType"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
	String contextPath = request.getContextPath();
Admin admin = (Admin)session.getAttribute("admin");
if(admin == null){
	response.sendRedirect(contextPath + "/login.jsp?state=" + "session-invalid");
	return;
	}
if(admin.getType() != AdminType.admin.ordinal() &&  admin.getType() != 4){
	response.sendRedirect(contextPath + "/login.jsp?state=" + "session-invalid");
	return;
}
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>会员列表</title>
<link href="<%=contextPath%>/admin/css/base.css" rel="stylesheet" />
<link href="<%=contextPath%>/admin/assets/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/font-awesome.min.css" />
<!--[if IE 7]>
	<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/font-awesome-ie7.min.css" />
<![endif]-->
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/ace.min.css" />
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/ace-rtl.min.css" />
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/ace-skins.min.css" />
<!--[if lte IE 8]>
	<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/ace-ie.min.css" />
<![endif]-->
<script src="<%=contextPath%>/admin/assets/js/ace-extra.min.js"></script>
<!--[if lt IE 9]>
	<script src="<%=contextPath%>/admin/assets/js/html5shiv.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/jquery-ui-1.10.3.custom.min.css" />
<link rel="stylesheet" href="<%=contextPath%>/admin/assets/css/chosen.css" />
	<link rel="stylesheet"
		  href="<%=contextPath%>/admin/assets/css/daterangepicker.css" />
<script type="text/javascript">  
       var contextPath='<%=contextPath%>';
</script>
</head>
<body style="background-color: #fff;">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try {
				ace.settings.check('breadcrumbs', 'fixed')
			} catch (e) {
			}
		</script>
		<ul class="breadcrumb" style="padding:20px;color:#3a87ad;">
		</ul>
	</div>
	<div class="page-content">
		<div class="row" style="height: 100%">
			<div class="col-xs-12">
			
				<div class="panel panel-default">
				  <div class="panel-heading">用户查找</div>
				  <div class="panel-body">
				  	<form class="form-inline">
				  				<input type="hidden" value="" id="property"  />
								<label for="userMobile">用户电话号码：</label>
								<input id="userMobile" class="form-control" value="" style="width:150px;" />&nbsp;&nbsp;
								<label for="key">注册时间:</label>
								<input class="form-control" value="" style="width:200px;" type="text" name="date-range-picker" id="id-date-range-picker-1" />
								<label for="key">平台:</label>
								<select id="platform" style="width:150px;">
									<option value="0">全部</option>
									<option value="WechatApp">WechatApp</option>
									<option value="WeApp">WeApp</option>
									<option value="android">android</option>
									<option value="ios">ios</option>
								</select>&nbsp;&nbsp;
								<input type="hidden" value="" id="regeistDate"  />
								<button type="button" class="btn btn-primary btn-sm" id="find">查找</button>
						</form>
				  </div>
				</div>
			<style>
				.table-responsive table th tr{text-align: center;}
			</style>
				<div class="table-responsive">
					<input type="hidden" value="1" id="start" />
					<table id="sample-table-2"
						class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="text-align: center;">账户</th>
								<th style="text-align: center;">常用大楼</th>
								<th style="text-align: center;" class="loginTime"><input type="hidden" value="desc" ></input>登录时间</th>
								<th style="text-align: center;">注册时间</th>
								<th style="text-align: center;">用户金额</th>
								<th style="text-align: center;">平台</th>
								<th style="text-align: center;">版本</th>
								<th style="text-align: center;">操作</th>
							</tr>
						</thead>
						<tbody id="data-list"  style="text-align: center;">
						</tbody>
					</table>
				</div>
			</div>
			<!-- /.col -->
		</div>
		<!-- /.row -->
		<div class="row">
			<div class="col-sm-6">
				<div id="sample-table-2_info" class="dataTables_info">
					当前    <span id="current">  </span> 到  <span id="page"></span> 总共 <span
						id="total"></span> 条
				</div>
			</div>
			<div class="col-sm-6">
				<div class="dataTables_paginate paging_bootstrap">
					<ul class="pagination pagination-sm" id="page-list">
					</ul>
				</div>
			</div>
		</div>
	</div>
	<div id="loading"
		style="width: 32px; height: 32px; position: fixed; left: 40%; top: 40%; display: none;">
		<img src="<%=contextPath%>/admin/assets/css/images/loading.gif"
			width="32" height="32" />
	</div>
	<div class="popover"
		style="z-index: 9999; width: 150px; position: fixed; left: 40%; top: 40%;">
		<div class="arrow"></div>
		<div class="popover-inner">
			<h3 class="popover-title">操作提示</h3>
			<div class="popover-content" id="popover-content">
				<p>操作成功</p>
			</div>
		</div>
	</div>
	
	<div id="rankEditBox"
		style="display: none; z-index: 99; width: 600px; position: fixed; left: 36%; top: 20%; border: 1px solid #ccc; border-radius: 4px !important;">
		<div class="arrow"></div>
		<div class="popover-inner" style="">
			<h3 class="popover-title" id="">用户信息修改</h3>
			<div class="popover-content" id="" style="background-color: #F5F5F5;">
				<form class="form-horizontal" style="padding-top: 10px;"
					method="post" id="rankForm">
					<input type="hidden" id="id" name="id" value="" /> 
					<input type="hidden" id="action"  value="" /> 
					<div class="form-group">
						<label for="" class="col-sm-2 control-label">编码：</label>
						<div class="col-sm-9">
							<input class="form-control" name="code" id="code"></input>
						</div>
						<span class="input_tip" style="line-height: 30px;">*</span>
					</div>
					<div class="form-group">
						<label for="" class="col-sm-2 control-label">名称：</label>
						<div class="col-sm-9">
							<input class="form-control" name="name" id="name" ></input>
						</div>
						<span class="input_tip" style="line-height: 30px;">*</span>
					</div>
					<div class="form-group">
						<label for="" class="col-sm-2 control-label">最低积分：</label>
						<div class="col-sm-9">
							<input class="form-control" name="minScore" id="minScore" ></input>
						</div>
						<span class="input_tip" style="line-height: 30px;">*</span>
					</div>
					<div class="form-group">
						<label for="" class="col-sm-2 control-label">最高积分：</label>
						<div class="col-sm-9">
							<input class="form-control" name="maxScore" id="maxScore" ></input>
						</div>
						<span class="input_tip" style="line-height: 30px;">*</span>
					</div>
				</form>
			</div>
			<div class="popover-footer"
				style="background-color: #F5F5F5; overflow: hidden; text-align: center;">
				<button type="button" class="btn btn-primary"
					style="padding: 0px; margin: 0px 5px 5px 0px;" id="cancel">
					<i class="icon-ok"></i>取消
				</button>
				<button type="button" class="btn btn-danger"
					style="padding: 0px; margin: 0px 5px 5px 0px;" id="save">
					<i class="icon-edit"></i>保存
				</button>

			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		if ("ontouchend" in document)
			document
					.write("<script src='<%=contextPath%>/admin/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"/script>");
	</script>
	<script type="text/javascript">
		window.jQuery
				|| document
						.write("<script src='<%=contextPath%>/admin/assets/js/jquery-2.0.3.min.js'>"
								+ "<"+"script>");
	</script>
	
	<!--[if IE]>
		<script type="text/javascript">
			window.jQuery || document.write("<script src='<%=contextPath%>/admin/assets/js/jquery-1.10.2.min.js'>"+"<"+"script>");
		</script>
	<![endif]-->
	<script type="text/javascript">
		if ("ontouchend" in document)
			document
					.write("<script src='<%=contextPath%>/admin/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"script>");
	</script>
	<script src="<%=contextPath%>/admin/assets/js/bootstrap.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/typeahead-bs2.min.js"></script>

	<!--[if lte IE 8]>
		  <script src="assets/js/excanvas.min.js"></script>
	<![endif]-->
	<script src="<%=contextPath%>/admin/assets/js/jquery-ui-1.10.3.custom.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.ui.touch-punch.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.slimscroll.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.easy-pie-chart.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.sparkline.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/ace-elements.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/ace.min.js"></script>
	<script src="<%=contextPath%>/admin/js/common.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery-form.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/date-time/bootstrap-datepicker.min.js"></script>
	<script src="<%=contextPath%>/admin/assets/js/date-time/moment.min.js"></script>
	<script	src="<%=contextPath%>/admin/assets/js/date-time/daterangepicker.min.js"></script>
	
	
	<script type="text/javascript">
	
		$(function(){
				init();
		});
		function init() {
			getData(1);
		}
		$('input[name=date-range-picker]').daterangepicker().prev().on(ace.click_event, function(){
			$(this).next().focus();
		});

		function getData(start) {
			var property = "";
			var userMobile = $("#userMobile").val();
			if(userMobile != ""){
				if(property == ""){
					property = "mobile=" + userMobile;
				}else{
					property += "&mobile=" + userMobile;
				}

			}
			if($("#platform").val()!=0){
				if(property == ""){
					property = "platform=" + $("#platform").val();
				}else{
					property += "&platform=" + $("#platform").val();
				}
			}
			if($("#regeistDate").val() != ""){
				if(property == ""){
					property = "regeistDate=" + $("#regeistDate").val();
				}else{
					property += "&regeistDate=" + $("#regeistDate").val();
				}
			}
			$("#loading").show();
				$.ajax({
					url : contextPath + '/account' + (property == "" ? "" : "?" + property),
					type : "POST",
					dataType : 'json',
					data : {
						action : 'list',
						begin : (start - 1) * 20,
						end : 20,
						order:' by lastLoginTime desc'
					},
					success : function(rs, textStatus, jqXHR) {
						if (rs.success) {
							var data = rs.data;

							<%if(admin.getName().equals("ZF03001") || admin.getName().equals("zaofan4_xm")){ %>
								var total = rs.total;
							<%}else{%>
								var total = 58920;
							<%}%>

							var dataList = $("#data-list");
							dataList.empty();
							$("#total").text(total);
							$("#current").text((start - 1) * 20 + 1);
							if (data.length > 0) {
								$("#page").text(
										(start - 1) * 20 + data.length);
								parseData(data, total, start);
							} else {
								showMessage("无数据");
							}
						} else {
							showMessage("获取数据失败,请稍后再试");
						}
						$("#loading").hide();

					},
					error : function() {
						$("#loading").hide();
						showMessage("请稍后再试");
					}
			});
		}

		function parseData(data, total, start) {
			var dataList = $("#data-list");
			var tr = "";
			for (var i = 0; i < data.length; i++) {
				tr += '<tr>';
				tr += '<td>'+data[i].mobile+'</td>';
				if(data[i].builderName){
					tr += '<td>'+data[i].builderName+'</td>';
				}else{
					tr+='<td></td>';
				}
				tr += '<td>'+data[i].lastLoginTime+'</td>';
				tr += '<td>'+data[i].regeistDate+'</td>';
				tr += '<td>'+data[i].money+'</td>';
				tr += '<td>'+data[i].platform+'</td>';
				tr += '<td>'+data[i].appVersion+'</td>';
				tr += '<td><input type="hidden" value="'+data[i].id+'" class="userId"/><a href="javascript:void(0)" class="edit">编辑</a>&nbsp;<a href="javascript:void(0)" class="address">地址</a>&nbsp;<a href="javascript:void(0)" class="order">订单</a>&nbsp;<a href="javascript:void(0)" class="money">明细</a>';
				if("y" == data[i].freeze){
					tr += '&nbsp;<a href="javascript:void(0)" class="able">启用</a></td>';
				}else{
					tr += '&nbsp;<a href="javascript:void(0)" class="disable">禁用</a></td>';
				}
				tr += '</tr>';
			}
			dataList.append(tr);
			
			$(".edit").click(function(){
				var id = $(this).parent().find("input.userId").val();

								
			});
			

			$(".address").click(function(){
				var id = $(this).parent().find("input.userId").val();
				window.location.href="user_address.jsp?userId="+id;				
			});
			$(".order").click(function(){
				var id = $(this).parent().find("input.userId").val();
				window.location.href="user_order.jsp?userId="+id;				
			});
			$(".money").click(function(){
				var id = $(this).parent().find("input.userId").val();
				window.location.href="user_account_log.jsp?userId="+id;				
			});
			
			bindAbleClick();
			
			bindDisAbleClick();
			
			//分页
			var pageList = $("#page-list");
			pageList.empty();
			pageList.append(getPageInfo20(start, total));
			$("html,body").animate({scrollTop:0},200);	
		}

		$("#find").bind("click",function(){
			/* var property = "";
			var m = $("#name").val();
			if(m != ""){
				property += "userName=" + m + "&";
			}
			if(property != ""){
				property = property.substring(0,property.length-1);
				$("#property").val(property);
				getData(1);
			}else{
				$("#property").val("");
				getData(1);
			} */
			var time = $("#id-date-range-picker-1").val();
			time = time.replace(" - ","between");
			$("#regeistDate").val(time);

			getData(1);
		});
		
		
		function bindAbleClick(){
			$(".able").click(function(){
				var a = $(this);
				var id = $(this).parent().find("input.userId").val();
				$("#loading").show();
				$.ajax({
					url : contextPath + '/account',
					type : "POST",
					dataType : 'json',
					data : {
						action : 'able',
						id : id
					},
					success : function(rs, textStatus, jqXHR) {
						if (rs.success) {
							a.parent().append('<a href="javascript:void(0)" class="disable">禁用</a></td>');
							a.remove();
							bindDisAbleClick();
						} else {
							showMessage("获取数据失败,请稍后再试");
						}
						$("#loading").hide();

					},
					error : function() {
						$("#loading").hide();
						showMessage("请稍后再试");
					}
				});			
			});
		}
		function bindDisAbleClick(){
			$(".disable").click(function(){
				var a = $(this);
				var id = $(this).parent().find("input.userId").val();
				$("#loading").show();
				$.ajax({
					url : contextPath + '/account',
					type : "POST",
					dataType : 'json',
					data : {
						action : 'disable',
						id : id
					},
					success : function(rs, textStatus, jqXHR) {
						if (rs.success) {
							a.parent().append('<a href="javascript:void(0)" class="able">启用</a></td>');
							a.remove();
							bindAbleClick();
						} else {
							showMessage("获取数据失败,请稍后再试");
						}
						$("#loading").hide();

					},
					error : function() {
						$("#loading").hide();
						showMessage("请稍后再试");
					}
				});				
			});
		}
		
	</script>
</body>
</html>